//
//  ECUIButton_Sort.m
//  Edu_iOS2018
//
//  Created by yanyan on 2018/1/6.
//  Copyright © 2018年 yanyan. All rights reserved.
//

#import "ECUIButton_Sort.h"

@implementation ECUIButton_Sort
-(void)setSelectedState:(KHButtonState)selectedState
{
    _selectedState = selectedState;
    if (self.selectedState == KHButtonStateNormal) {
        [self setImage:[UIImage imageNamed:@"category_sort_price_normal"] forState:UIControlStateNormal];
        self.selected = NO;
    }else{
        self.selected = YES;
        if (self.selectedState == KHButtonStateSortDown) {
            [self setImage:[UIImage imageNamed:@"category_sort_price_down"] forState:UIControlStateSelected];
            
        }else{
            [self setImage:[UIImage imageNamed:@"category_sort_price_up"] forState:UIControlStateSelected];
            
        }
    }
    
    
}
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.selectedState = KHButtonStateNormal;
        self.selected = NO;
        [self setImage:[UIImage imageNamed:@"category_sort_price_normal"] forState:UIControlStateNormal];
        [self setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        [self setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
        self.titleLabel.textAlignment = NSTextAlignmentRight;
        
    }
    return self;
}
//-(CGRect)titleRectForContentRect:(CGRect)contentRect
//{
//    return CGRectMake(0, 0, CGRectGetWidth(contentRect)*0.7, CGRectGetHeight(contentRect));
//}
//-(CGRect)imageRectForContentRect:(CGRect)contentRect
//{
//    CGFloat height = 12;
//    CGFloat top = (CGRectGetHeight(contentRect)-height)/2;
//    return CGRectMake(CGRectGetWidth(contentRect)*0.7,  top, height,height);
//}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
